<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class user_model extends CI_Model {

	function __construct()
	{
		parent::__construct();
	}
	
	function get_autentikasi_user($user, $pass){
		$result = $this->db->select('username, password')
				->from('user_auth')
				->where(array('username' => $user, 'password', md5($pass)))
				->get();
		return $result->result_array();
	}
	
	/**
	 * Mendapatkan data semua user
	 */
	function get_all_user()
	{
		$this->db->select('user.NAMA, user.USERNAME, user.ID_ROLE, user.ID_USER, user.EMAIL, role.ID_ROLE, role.NAMA_ROLE');
		$this->db->from('user');
		$this->db->join('role', 'role.id_role = user.id_role', 'left outer');
		return $this->db->get();
	}
	/*
	function get_role($id){
		return $this->db->select('*')
				->from('role')
				->where('id_role',$id);
	}
	
	/**
	 * Menambah data user
	 */
	function insert_user($user)
	{
		$this->db->insert('user', $user);
	}
	
	function delete_user($id){
		$this->db->where('ID_USER', $id);
		$this->db->delete('user');
	}
	
	function update_user($id, $data){
		$this->db->where('ID_USER',$id)
				->update('user',$data);
		
	}
	
}

?>